﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SuperJoe.Framework.UnitOfWorkSql
{
    public interface IUnitOfWork
    {
        /// <summary>
        /// 启动一个单元事务
        /// </summary>
        void Begin();

        /// <summary>
        /// 结束单元事务
        /// </summary>
        void End();


        /// <summary>
        /// 回滚单元事务
        /// </summary>
        void Rollback();

        /// <summary>
        /// 执行多个sql命令，如果单元事务被启动，那么需要调用End方法，来最终将数据提交到数据库。返回影响的记录行
        /// </summary>
        /// <param name="commands"></param>
        int ExecuteCommand(IEnumerable<UOWCommand> commands);

        object ExecuteScalar(string sql, IDictionary<string, object> parameters=null);

        DataSet ExecuteDataSet(string sql, IDictionary<string, object> parameters = null);

    }
}
